package pers.liyan.shi.springboot.mapper;

import org.apache.ibatis.annotations.*;
import pers.liyan.shi.springboot.bean.Department;
//不加这个注解在使用@Autowired注入时会报错
//@Repository
//指定这是一个操作数据库的mapper
//@Mapper
public interface DepartmentMapper {

    //查询
    @Select("select * from department where id = #{id}")
    public Department getDeptByid(Integer id);

    //删除
    @Delete("delete from department where id = #{id}")
    public int deleteDeptById(Integer id);

    //插入
    //把自动生成的主键赋值到指定的 keyProperty 属性中
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into department(department_mame) values (#{departmentName})")
    public int insertDept(Department department);

    //修改
    @Update("update department set department_mame = #{departmentName} where id = #{id}")
    public int updateDept(Department department);
}

